var jsonp = {
	ide_tip:function(json){
		//var data = [[["I", "RC1"], ["IBM", 1234, "RIC"], ["IACVB", 10234, "EDCOI2D"], ["I4BMDF", 1234, "RIC2"]], [["I1", 123, "RIC1"], ["I2BM", 1234, "RIC"], ["IB3MACVB", 10234, "EDCOI2D"], ["I4BM", 1234, "RIC2"]]];
		//var j = {"ErrorMsg":null,"TipList":[{"Type":"QUOTRON","Value":"A"},{"Type":"RIC","Value":"A"},{"Type":"ABU DHABI SYMBOL","Value":"A"},{"Type":"DBS PRICE SOURCE CODE","Value":"A"},{"Type":"LOCAL EXCHANGE CODE","Value":"A 2000 BLB"}]};
		if(json !== null){
			
			//if(type.length > 200) // clear the cache.
			ViewData.asset.tips_type = {};
			var type = ViewData.asset.tips_type;	
			for(var i in json){
				if(!type[json[i][0]])
					type[json[i][0]] = [];
				type[json[i][0]].push(json[i][1]);				
			}
			
			ViewData.asset.tips.reset(json);
			return json;
		}
	},
	Root: function(json){
		return jsonp.getResult(json, ViewData.Root.table, ViewData.Root.alert);
	},
	URIC: function(json){
		return jsonp.getResult(json, ViewData.URIC.table, ViewData.URIC.alert);
	},
	getResult: function(json, table, alert){
		if(json !== null){
			if(json.length ==0){
				alert.set('msg', ViewData.err.norecord)
				return [];
			}
			table.set('data', json);
			return json
		}		
	},
	Login: function(json){
		if(json.rights === undefined){
			ViewData.Login =  {
				err: ViewData.err.login
			}
		}
		else{
			var asset = {};
			_.each(json.rights.asset, function(ast){
				asset[ast] = json.assetCategory[ast];
			});
			
			ViewData.Login = {
				Asset: asset
				,Bulk: jsonp.keyCheck(json.rights.bulkWithPriority)
				,Root: jsonp.keyCheck(json.rights.root)
				,URIC: jsonp.keyCheck(json.rights.uric)
				,token: json.sessionID
				,usr: ViewData.Login.usr
			}
		}
		for(var i in Auth.ctrl){
			Auth.ctrl[i].trigger('user');
		}	
	}
	, keyCheck: function(key){
		var item = 0;
		if(key !== undefined)
			item = 1;
		return item;		
	}
	
}
